package demo.day11_CollectionAddpackage.List;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/4-08-04-18:57
 * @Description：demo.day11_CollectionAddpackage.List
 */
public class TreeSetTest1 {
    public static void main(String[] args) {
        TreeSet<String> set = new TreeSet(Arrays.asList("HashSet","ArrayList","HashMap","HashMap","TreeSet","LinkedList"));
        System.out.println(set);      //升序

        TreeSet<String> set2 = new TreeSet(new Comparator<String>(){
            @Override
            public int compare(String o1, String o2) {
                return o2.compareTo(o1);
            }
        });
        set2.addAll(set);
        System.out.println(set2);     //降序
    }
}
